<?php

/**
 * 首页
 * @copyright (c) 2013, Mr.Wang
 * @author Mr.Wang <281762391@qq.com>
 */
class OrderAction extends UserAction {

    function _filter(&$map) {
        $map['uid'] = session('uid');
    }

    function view() {
        $order        = M("Order")->find($_GET['order_id']);
        $order_detail = M("OrderDetail")->where("order_id = '{$order['order_id']}'")->select();
        $this->assign("order", $order);
        $this->assign("order_detail", $order_detail);
        $this->display();
    }

    function confirm() {
        //恢复指定记录
        $name      = $this->getActionName();
        $model     = D($name);
        $pk        = $model->getPk();
        $id        = $_GET [$pk];
        $condition = array($pk => array('in', $id));
        $saveData = array(
            "confirm_status" => 1
        );
        if (false !== $model->where($condition)->save($saveData)) {
            $this->success('确认成功！', U("Shop/Order"));
        } else {
            $this->error('确认失败！');
        }
    }

}
